package org.ben.queue;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;

import org.junit.Test;

public class PriorityQueueTest {
    @Test
    public void testA() {
        Model m1 = new Model(1);
        Model m2 = new Model(2);
        Model m3 = new Model(3);
        PriorityQueue<Model> pq = new PriorityQueue<Model>();
        pq.add(m3);
        pq.add(m1);
        pq.add(m2);
        Iterator<Model> mt = pq.iterator();
        while(mt.hasNext())
            System.out.println(mt.next().getPriority());
        System.out.println(pq.poll().getPriority());
        System.out.println(pq.poll().getPriority());
    }

    @Test
    public void testB() {
        List<Model> temp = new LinkedList<Model>();
        while (true) {
            temp.add(new Model(1));
        }
    }

    @Test
    public void testC() {
        System.out.println((int)3.9);
    }
}

class Model implements Comparable<Model> {
    private int priority;

    Model(int i) {
        this.priority = i;
    }

    public int getPriority() {
        return this.priority;
    }

    @Override
    public int compareTo(Model o) {
        if(this.priority > ((Model)o).getPriority())
            return -1;
        else if(this.priority == ((Model)o).getPriority())
            return 0;
        else if(this.priority < ((Model)o).getPriority())
            return 1;
        return -1;
    }
}
